<template>
  <!--<bpm-c-toptitle :title="(lang === langEnum.zh ? '附件' : 'Attachment')+'('+ attachListLength +')'" :noneBefore="true" :isCollapse="true">-->
  <bpm-c-toptitle :title="(lang === langEnum.zh ? '附件' : 'Attachment')+'('+ attachListLength +')'" :isCollapse="true">
    <div class="attachmentdiv">
      <iframe v-if="attachURL.length > 0"
              :src="attachURL"
              width="100%"
              height="300px" />
    </div>
  </bpm-c-toptitle>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'bpmDAttacharea',
  props: {
    allowCreate: {
      type: Boolean,
      default: true
    },
    allowUpdate: {
      type: Boolean,
      default: true
    },
    allowDelete: {
      type: Boolean,
      default: true
    },
    allowUpdateOthers: {
      type: Boolean,
      default: false
    },
    allowDeleteOthers: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return { }
  },
  computed: {
    ...mapState(['tsId', 'tsPiid', 'lang', 'langEnum', 'attachListLength']),
    attachURL () {
      if (this.tsId.toString().length < 5) { return '' }
      let url = window.location.protocol + '//' + window.location.host
      console.log('host----->', window.location.host)
      if (url === 'http://localhost:8080') {
        url = 'http://bpmdev02.whchem.com' // 本地调试链接开发，需要登录或者单点
      }
      // url = 'http://bpmuat.whchem.com'
      url += '/teamworks/fastExecuteServiceByName.jsp?processApp=EBCOMMA&serviceName=UI_Attachment'
      url += '&tw.local.instanceId=' + this.tsId
      url += '&tw.local.allowCreate=' + this.allowCreate
      url += '&tw.local.allowUpdate=' + this.allowUpdate
      url += '&tw.local.allowDelete=' + this.allowDelete
      url += '&tw.local.allowUpdateOthers=' + this.allowUpdateOthers
      url += '&tw.local.allowDeleteOthers=' + this.allowDeleteOthers
      console.log('attachframe url is......', this.tsId)
      return url
    }
  },
  methods: {
    // ...mapActions(['getAttachmentList'])
  },
  created () {
    // this.getAttachmentList({me: this, async: true})
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .attachmentdiv {
    width: 100%;
    height: 300px;
    background-color: #eff3f6;
  }
</style>
